home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLISRC.ZIP / MEMSCREE.C < prev    next >
C/C++ Source or Header  |  1989-11-24  |  876b  |  52 lines

  1.  
  2. #include "aai86.h"
  3. #include "aascreen.h"
  4.  
  5. Vscreen *
  6. aa_alloc_mem_cel(int x, int y, int w, int h)
  7. {
  8. Vscreen *vs;
  9.  
  10. if ((vs = aa_malloc(sizeof(*vs))) != NULL)
  11.     {
  12.     i86_bzero(vs, sizeof(*vs) );
  13.     vs->x = x;
  14.     vs->y = y;
  15.     vs->bpr = vs->w = w;
  16.     vs->h = h;
  17.     vs->psize = (long)w*h;
  18.     if ((vs->allocedp = aa_malloc((unsigned)vs->psize+16)) == NULL)
  19.         {
  20.         aa_free(vs);
  21.         return(NULL);
  22.         }
  23.     if ((vs->cmap = aa_malloc(AA_COLORS*3)) == NULL)
  24.         {
  25.         aa_free_mem_screen(vs);
  26.         return(NULL);
  27.         }
  28.     /* force even paragraph allignment */
  29.     vs->p = i86_make_ptr(0, i86_ptr_seg(vs->allocedp)+1);
  30.     }
  31. return(vs);
  32. }
  33.  
  34. Vscreen *
  35. aa_alloc_mem_screen()
  36. {
  37. return(aa_alloc_mem_cel(0, 0, AA_XMAX, AA_YMAX));
  38. }
  39.  
  40. void aa_free_mem_screen(Vscreen *vs)
  41. {
  42. if (vs)
  43.     {
  44.     if (vs->cmap)
  45.         aa_free(vs->cmap);
  46.     if (vs->allocedp)
  47.         aa_free(vs->allocedp);
  48.     aa_free(vs);
  49.     }
  50. }
  51.  
  52.